<template>
	<view>
		
		<view class="notice-item" v-for="(item,i) in res" :key="i">
			<text class="time">{{item.create_time}}</text>
			<view class="content" @click="jumpgoods" :data-id='item.id'>
				<text class="title">{{item.article_title}}</text>
				<view class="img-wrapper">
					<image class="pic" :src="item.resp_img"></image>
					<!-- <view class="cover">
						活动结束
					</view> -->
				</view>
				<text class="introduce">{{item.content}}</text>
				<view class="bot b-t">
					<text>查看详情</text>
					<uni-icons type="arrowright" size="24"></uni-icons>
				</view>
			</view>
		</view>
		
		<!-- <uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more> -->
	</view>
</template>

<script>
	import uniIcons from '@/components/uni-icons/uni-icons.vue';
	// import uniLoadMore from '@/components/uni-load-more.vue';
	export default {
		components: {
			uniIcons
		},
		data() {
			return {
				res:[],
				openid:'',	
				
				loadingText: '加载中...',
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				page: 1,
				timer:{},
			}
		},
		onLoad: function () {
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../../index/index'
					});
				}
			});
		},
		onPullDownRefresh() {
			this.page = 1
			this.loadingType = 0;//将loadingType归0重置
			this.setAjax()
			setTimeout(function () {
					uni.stopPullDownRefresh();
			}, 1000);
		},
		// 上拉加载
		onReachBottom(){
			if (this.timer != null) {
				clearTimeout(this.timer)
			}
			this.timer = setTimeout(()=> {
				this.getmorenews()
			}, 1000);
		},
		methods: {
			setAjax(){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=article.article_index&app=1',
					method: 'GET',
					data:{
						openid: this.openid,
						cateid: 12
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						this.res = res.data.article
					},
					fail: () => {},
					complete: () => {}
				});
				uni.hideLoading()
			},
			getmorenews() {
				// let o = this
				// this.page++;//每触底一次 page +1
				// if (this.loadingType !== 0) {//loadingType!=0;直接返回
				// 	return false;
				// }
				// this.loadingType = 1;
				// uni.showNavigationBarLoading();//显示加载动画
				// uni.request({
				// 	url:'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=article.article_index&app=1' + this.page,
				// 	method: 'POST',
				// 	data: {
				// 		openid: this.openid,
				// 		session_id: uni.getStorageSync("sessionid")
				// 	},
				// 	header:{'Content-Type':'application/x-www-form-urlencoded'},
				// 	success: function(res) {
				// 		if(res.data.code == 999){
				// 			uni.navigateTo({
				// 				url:'/pages/999/999'
				// 			})
				// 		};
				// 		if (res.data.data.list == '' || res.data.data.list == null) {//没有数据
				// 			o.loadingType = 2;
				// 			uni.hideNavigationBarLoading();//关闭加载动画
				// 			return;
				// 		}
				// 		var tpcList = res.data.data.list
				// 		o.res = o.res.concat(tpcList);//将数据拼接在一起
				// 		o.loadingType = 0;//将loadingType归0重置
				// 		uni.hideNavigationBarLoading();//关闭加载动画
				// 	}
				// });
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
			jumpgoods(e) {
				uni.navigateTo({
					url: '../../pageA/essay/essay?essaysid=' + e.currentTarget.dataset.id
				});
			},
			
			
		}
	}
</script>

<style lang='scss'>
	page {
		background-color: #f7f7f7;
		padding-bottom: 30upx;
	}
	.active {
		 border-bottom: 5upx solid #000;
		 color: #000;
		 }
	.notice-item {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.time {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 80upx;
		padding-top: 10upx;
		font-size: 26upx;
		color: #7d7d7d;
	}

	.content {
		width: 710upx;
		padding: 0 24upx;
		background-color: #fff;
		border-radius: 4upx;
	}

	.title {
		display: flex;
		align-items: center;
		height: 90upx;
		font-size: 32upx;
		color: #303133;
	}

	.img-wrapper {
		width: 100%;
		height: 260upx;
		position: relative;
	}

	.pic {
		display: block;
		width: 100%;
		height: 100%;
		border-radius: 6upx;
	}
	.my-icon-test:before {
	      content: "\e634";
	    }
	.cover {
		display: flex;
		justify-content: center;
		align-items: center;
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, .5);
		font-size: 36upx;
		color: #fff;
	}

	.introduce {
		display: inline-block;
		padding: 16upx 0;
		font-size: 28upx;
		color: #606266;
		line-height: 38upx;
	}

	.bot {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 80upx;
		font-size: 24upx;
		color: #707070;
		position: relative;
	}

	.more-icon {
		font-size: 32upx;
	}
</style>
